<?php
namespace app\admin\logic;

use think\facade\Request;
use think\facade\View;

class Goods
{
    public static function setWhere()
    {
        $where=[];
        if (\request()->param('maxprice')!=''){
//            $where['price']=request()->param('maxprice');
            $where['maxprice']=\request()->param('maxprice');
        }
        if (\request()->param('minprice')!=''){
//            $where['price']=\request()->param('minprice');
            $where['minprice']=\request()->param('minprice');
        }

        if (\request()->param('startaddtime')!='' && \request()->param('endaddtime')!=''){

            $where['startaddtime']=\request()->param('startaddtime');
            $where['endaddtime']=\request()->param('endaddtime');

        }

        //模糊搜索
        if($show=Request::param("is_show"))
        {
            $where["is_show"]=$show;
        }


        if ($hot = Request::param('is_hot')){
            $where['is_hot']=$hot;
        }


        if ($down = Request::param('is_down')){
            $where['is_down']=$down;
        }


        if ( $cid = Request::param('cid')){
            $where['cid']=$cid;

        }







        if($keywords=Request::param("keywords")){
            $where["gname"]=$keywords;
        }









        //时间排序
        $order = request()->param('order');
        if ($order=='g.id asc'){
            View::assign('order','gaddtime desc');
            View::assign('asc',"↑");}
        else if ($order=='g.addtime desc'){
            View::assign('order','gaddtime asc');
            View::assign('asc',"↓");
        }
        else if ($order=='g.addtime asc'){
            View::assign('order','g.id asc');
            View::assign('asc','');
        }


        return ['where'=>$where,
                'order'=>$order
        ];
    }
}